package top.wshape1.shiziapi.mock.service;

import com.baomidou.mybatisplus.extension.service.IService;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import top.wshape1.shiziapi.mock.domain.Mock;
import top.wshape1.shiziapi.mock.domain.vo.MockVo;

import javax.script.ScriptException;
import java.util.List;

/**
 * @author Wshape1
 * @description 针对表【t_mock】的数据库操作Service
 * @since 2023-10-09 21:35:11
 */
public interface MockService extends IService<Mock> {

    /**
     * 创建Mock
     *
     * @param mock
     * @param id
     * @return mockId
     */
    long create(Mock mock, Long id);

    /**
     * 获取Mock并检查userID
     *
     * @param mockId
     * @param userId
     * @return
     */
    Mock getByIdAndUserId(String mockId, Long userId);

    /**
     * 更新Update
     *
     * @param mock
     * @param id
     */
    void update(Mock mock, Long id);

    /**
     * 删除Mock配置
     *
     * @param mockId
     * @param id
     */
    void remove(Long mockId, Long id);

    /**
     * 查询用户的所有Mock配置
     *
     * @param userId
     * @param keyword
     * @return
     */
    List<MockVo> list(Long userId, String keyword);

    /**
     * Mock请求
     *
     * @param userId
     * @param path
     * @param request
     * @param response
     * @return
     */
    Object mockRequest(Long userId, String path, HttpServletRequest request, HttpServletResponse response) throws ScriptException;
}
